<%@ Page language="c#" %>

function Refresh(app)
{
	var result;
	var xmlHttp;
	var doc;
	var response;
	var responseDocument;
	var status;
	var post;
	
	try
	{		
	
		xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");

		xmlHttp.Open("POST", app + "/Admin/Webservices/PageSvc.asmx/Refresh", false);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.Send();

		doc = xmlHttp.responseXML;
		if (doc.parseError.errorCode != 0 || doc.xml == '')
		{
			alert('Refresh - unable to execute request' + doc.parseError.errorCode + ':' + doc.xml + ':' + xmlHttp.responseText );
		}
		else
		{
			response = doc.documentElement.firstChild.text;
			/*alert(response);*/
			
			/* MsXml modif */
			responseDocument = new ActiveXObject("Msxml2.DOMDocument");
			
			responseDocument.loadXML(response);
			
			if (responseDocument.parseError.errorCode != 0 || responseDocument.xml == '')
			{
				alert('unable to retrieve read response');
			}
			else
			{
			    
				status = responseDocument.documentElement.firstChild;
				switch(status.text)
			    {
			        case "delog": alert('You were delogged');
			                      break;
			        case "maintenance": alert("This website is temporarily unavailable. Maintenance tasks are been performed. Sorry for the inconvenience.");
			                            break;
                    case "failed": alert("Refresh failed");
                    default: break;
			    }
			}
		}	

		setTimeout("Refresh('" + app + "')", 30000);
	}
	catch(e)
	{
		alert(e.message);
	}	
}

<% if  (HttpContext.Current.Request.UrlReferrer != null && HttpContext.Current.Request.UrlReferrer.ToString().IndexOf("SiteNote_Mode") != -1)
	{%>
        setTimeout("Refresh('<%= CrossFactory.SiteNote.Components.Utils._ApplicationPath + CrossFactory.SiteNote.Components.Settings._settings.VirtualPath %>')", 30000);
 <%
    }
     %>